package org.jeecg.modules.hc.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
public enum HcPaymentMethodEnum {
    ALIPAY("alipay", "支付宝"),
    WXPAY("wxpay", "微信"),
    WALLET("wallet", "钱包"),
    WALLET_WXPAY("wallet_wxpay", "钱包+微信"),
    WALLET_ALIPAY("wallet_alipay", "钱包+支付宝"),
    PC_WX("pc_wx", "pc+微信"),
    PC_ZFB("pc_zfb", "pc+支付宝"),
    ;

    @EnumValue
    private final String value;
    @JsonValue
    private final String name;

    HcPaymentMethodEnum(String value, String name) {
        this.value = value;
        this.name = name;
    }

    public static HcPaymentMethodEnum get(String val) {
        Optional<HcPaymentMethodEnum> first = Arrays.stream(HcPaymentMethodEnum.values()).filter(e -> e.getValue().equals(val)).findFirst();
        return first.orElse(null);
    }

    public static HcPaymentMethodEnum getByName(String name) {
        Optional<HcPaymentMethodEnum> first = Arrays.stream(HcPaymentMethodEnum.values()).filter(e -> e.getName().equals(name)).findFirst();
        return first.orElse(null);
    }
}
